package com.example.gulimallware.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.example.common.utils.R;
import com.example.gulimallware.entity.WmsWareInfoEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.Objects;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.common.utils.PageUtils;
import com.example.common.utils.Query;

import com.example.gulimallware.dao.WmsWareSkuDao;
import com.example.gulimallware.entity.WmsWareSkuEntity;
import com.example.gulimallware.service.WmsWareSkuService;


@Service("wmsWareSkuService")
public class WmsWareSkuServiceImpl extends ServiceImpl<WmsWareSkuDao, WmsWareSkuEntity> implements WmsWareSkuService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<WmsWareSkuEntity> page = this.page(
                new Query<WmsWareSkuEntity>().getPage(params),
                new QueryWrapper<WmsWareSkuEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public R selectList(Map<String, Object> params) {

        IPage<WmsWareSkuEntity> page = page(new Query<WmsWareSkuEntity>().getPage(params),
                new LambdaQueryWrapper<WmsWareSkuEntity>()
                        .eq(Objects.nonNull(params.get("skuId")),WmsWareSkuEntity::getSkuId, params.get("skuId"))
                        .eq(Objects.nonNull(params.get("wareId")),WmsWareSkuEntity::getWareId, params.get("wareId"))
        );
        return R.ok().put("page", new PageUtils(page));
    }

}